


//Snake Game 
module main(
	
	input			clk,
	input			rst,
	
	
	//key
	input			key_up,
	input			key_down,
	input			key_left,
	input			key_right,
	
	//VGA	  AN430
	output		VGA_CLK,		//VGA CLK
	output		VGA_EN,
	output		H_SYNC,		//VGA Hor SYNC
	output		V_SYNC,		//VGA Ver SYNC
	output[23:0]	VGA_Data		//VGA data
		
);


wire VGA_pll;


wire	key_up_down;
wire	key_down_down;
wire	key_left_down;
wire	key_right_down;



wire[8:0]   x_addr;
wire[8:0]   y_addr;
wire[23:0]	data;    //game data


//gen 9M clock
AN430_PLL AN430_PLL_HP(
	
	.inclk0	(clk),
	.c0		(VGA_pll)
);


Snake_Game  Snake_Game_HP(
	
	.clk			(clk),
	.VGA_CLK		(VGA_pll),
	.rst			(rst),
	
	
	//key_control
	.up			(key_up_down),
	.down			(key_down_down),
	.left			(key_left_down),
	.right		(key_right_down),
	
	//addr
	.x_addr		(x_addr),
	.y_addr		(y_addr),

	//snake data
	.data			(data)
);



VGA_Driver  VGA_Driver_HP(

	.clk			(clk),
	.vga_clk		(VGA_pll),
	
	.rst			(rst),
		
	
	//坐标输出
	.x_addr		(x_addr),		//水平坐标
	.y_addr		(y_addr),		//竖直坐标
	
	
	.idata		(data),
	
	//VGA	
	.VGA_CLK		(VGA_CLK),
	.VGA_EN		(VGA_EN),
	.H_SYNC		(H_SYNC),		//行同步时序
	.V_SYNC		(V_SYNC),		//列同步时序
	.VGA_Data		(VGA_Data)//VGA数据	
);









btn_dis_shake 	#(
	
	.mode			(0)
)btn_dis_shake_HP1(
			
	.clk			(VGA_pll),
	.rst_n		(rst),
	

	.ikey			(key_up),	//按键输入
	.okey			(key_up_down)		//按键输出
);

btn_dis_shake 	#(
	
	.mode			(0)
)btn_dis_shake_HP2(
			
	.clk			(VGA_pll),
	.rst_n		(rst),
	

	.ikey			(key_down),	//按键输入
	.okey			(key_down_down)		//按键输出
);
btn_dis_shake #(
	
	.mode			(0)
)	btn_dis_shake_HP3(
			
	.clk			(VGA_pll),
	.rst_n		(rst),
	

	.ikey			(key_left),	//按键输入
	.okey			(key_left_down)		//按键输出
);
btn_dis_shake #(
	
	.mode			(0)
)	btn_dis_shake_HP4(
			
	.clk			(VGA_pll),
	.rst_n		(rst),
	

	.ikey			(key_right),	//按键输入
	.okey			(key_right_down)		//按键输出
);


endmodule 